<layout name="Layout/main" />

<form action="{:U('blog/add')}" method='post' class="form-horizontal"
	role="form">
	<div class="form-group">
		<label class="col-sm-1 control-label">文章标题:</label>
		<div class="col-sm-3">
			<input type='text' name="title" placeholder="请输入标题"
				class="form-control" />
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-1 control-label">分类:</label>
		<div class="col-sm-2">
			<select name='cid' class="form-control">
				<volist name='categorys' id='vo'>
				<option class="text-left" value="{$vo.id}"
					<if condition="$vo['lev'] eq 2">style="padding-left:{$vo['lev']*8}px;"
					<elseif condition="$vo['lev'] eq 3" />style="padding-left:{$vo['lev']*5}px;"</if>
					>{$vo.title}
				</option>

				</volist>
			</select>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-1 control-label">标签:</label>
		<div class="col-sm-11">
			<select class="tags col-sm-3" id='select_tags' name='tags[]'
				multiple="multiple">
				<!-- <option value="0">Alabama</option>
				<option value="2">Wyoming</option>
				<option value="1">hah</option>
				<option value="3">aa</option>
				<option value="4">aas</option>
				<option value="5">aag</option> -->
			</select>

		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-1 control-label">作者:</label>
		<div class="col-sm-3">
			<input type='text' name="author" class="form-control" value="phpstar" />
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-1 control-label">状&nbsp;&nbsp;态:</label>
		<div class="col-sm-3">
			<label class="radio-inline"><input type='radio' name='status'
				value="1" />未审核</label> <label class="radio-inline"><input
				type='radio' name='status' value="0" checked="checked" />已通过</label>

		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-1 control-label">属&nbsp;&nbsp;性:</label>
		<div class="col-sm-3">
			<label class="radio-inline"><input type='radio'
				name='recommend' value="1" />推荐</label> <label class="radio-inline"><input
				type='radio' name='recommend' value="0" checked="checked" />普通</label>

		</div>
	</div>

	<div id="wmd-editor" class="form-group">
		<div id="wmd-button-bar"></div>
		<textarea rows="12" id="wmd-input" name='content' class="wmd-textarea"></textarea>
		<div id="wmd-preview" class="wmd-panel"></div>

	</div>

	<div class="form-group">
		<div class="col-sm-2">
			<button type='submit'
				class=" col-sm-offset-2 col-sm-10 btn btn-success form-control">添加</button>
		</div>
	</div>

</form>
<script>
	$(function() {
		$(".tags").select2({
			tags : "true",
			placeholder : "请输入标签"
		});

	/* 	$("#select_tags").select2({
			ajax : {
				url : "{:U('blog/getags')}",
				dataType : 'json',
				delay : 250,
				type : 'post',
				data : function(params) {
					return {
						tag : params.term, // search term
						page : params.page
					};
				},
				processResults : function(data, page) {
					// parse the results into the format expected by Select2.
					// since we are using custom formatting functions we do not need to
					// alter the remote JSON data
					JSON.stringify(arr); 
					var arr=JSON.parse(data.list);
					alert(arr);
					return false;
					return {
						results : data.list
					};
				},
				cache : true
			},
			minimumInputLength : 1, */
		/*  /*  templateResult: formatRepo, // omitted for brevity, see the source of this page
		  templateSelection: formatRepoSelection // omitted for  brevity, see the source of this page */
		/* }); */

		/* $('.select2-search__field').on('keyup', function() {
			
			var tag = $(this).val();
			alert(tag);
			if (tag != '') {
				$.post("{:U('blog/getags')}",{tag:tag},function(d){
					alert(d);
				});
			}
		}) */
	})
</script>